package com.practice;


import org.junit.jupiter.api.Test;


/**
 * Created with IntelliJ IDEA.
 * Description:测试类
 * User: YJ
 * Date: 2023--02
 * Time: 15:47
 */
class SingleLinkedListTest {

    @Test
    void test1() {
        SingleLinkedList list = new SingleLinkedList();
        list.addFirst(1);
        list.addFirst(2);
        list.addFirst(3);
        list.addFirst(4);
        list.addFirst(5);
        System.out.println("----------while循环遍历-------------");
        list.loop1(value->{
            System.out.print(value + "-->");
        });
        System.out.println();
        System.out.println("----------for循环遍历-------------");
        list.loop2(a->{
            System.out.print(a + "-->");
        });
        System.out.println();
        System.out.println("----------迭代器遍历-------------");
        for (Integer value : list) {
            System.out.print(value + "-->");
        }
    }
    @Test
    void test2() {
        SingleLinkedList list = new SingleLinkedList();
        list.addLast(1);
        list.addLast(2);
        list.addLast(3);
        list.addLast(4);
        list.addLast(5);
        list.loop1(value->{
            System.out.print(value + "-->");
        });
    }
    @Test
    void test3() {
        SingleLinkedList list = new SingleLinkedList();
        list.addLast(1);
        list.addLast(2);
        list.addLast(3);
        list.addLast(4);
        list.addLast(5);
        list.insert(5,10);
        list.loop1(value->{
            System.out.print(value + "-->");
        });
    }
    @Test
    void test4() {
        SingleLinkedList list = new SingleLinkedList();
        list.addLast(1);
        list.remove(0);
        list.loop1(value->{
            System.out.print(value + "-->");
        });
    }

}